package com.logic.landseaserver.ws;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.logic.common.enums.HttpCodeEnum;
import com.logic.common.util.CommonResult;
import com.logic.common.util.CommonResultMap;
import com.logic.landseaserver.service.ISendMsgService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 *
 * 项目名称：system-server</br>
 * 类名称：SendMsgRest</br>
 * 类描述：</br>
 * 创建人：tony</br>
 * 创建时间：2017年7月17日 下午2:59:05</br>
 * @version 1.0
 *
 */
@Path("/sendMsg")
@Api(value = "sendMsg", description = "Send messages Rest WebServices", position = 42)
public class SendMsgRest {

    @Autowired
    private ISendMsgService sendMsgServiceImpl;

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    
    @POST
    @Path("/testSendMSG")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "测试：根据contractId推送微信公共号消息")
    public Response queryProjectAppartments(
            @ApiParam(value = "param", required = true)
            @QueryParam("contractId") Integer contractId, @QueryParam("billId") Integer billId, @QueryParam("billType")String billType) {
        CommonResultMap map = new CommonResultMap();
        try {
            String result = sendMsgServiceImpl.sendMessage(contractId,billType,billId);
            map.setData(result);
            map.setResult(CommonResult.SUCCESS);
        } catch (Exception e) {
            logger.error("queryProjectAppartments error.", e);
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }


}


